#ifndef CLIENT_H
#define CLIENT_H

#include <QWidget>
#include <QTcpSocket>
#include "protocol.h"
#include "reshandler.h"//为了新定义的类能用，先定义成员变量

QT_BEGIN_NAMESPACE
namespace Ui { class Client; }
QT_END_NAMESPACE

class Client : public QWidget
{
    Q_OBJECT

public:
    ~Client();
    void loadConfig();
    static Client& getInstance();
    void recvMsg();
    QTcpSocket m_tcpSocket;
    QString m_strLoginName;
    QString m_strOnlinenName;
    void handlePDU(PDU* pdu);
    ResHandler* m_prh;
    void sendPDU(PDU* pdu);
    QByteArray buffer;

public slots:
    void showConnect();//声明连接信号的处理槽函数

private slots:
    void on_regist_PB_clicked();
    void on_login_PB_clicked();

private:
    Ui::Client *ui;
    QString m_strIP;
    quint16 m_usPort;

    Client(QWidget *parent = nullptr);//构造函数私有化
    Client(const Client& instance) = delete;//拷贝构造
    Client& operator = (const Client&) = delete;//拷贝运算符
};
#endif // CLIENT_H
